﻿using System;
using System.CodeDom.Compiler;
using System.IO;

namespace FBGraph.ClientGenerator.CodeGen
{
    public abstract class CodeGenObject : ICodeGenObject
    {
        public abstract void Write(CodeGenWriter writer);

        public override String ToString()
        {
            return CodeGenObject.ToString(this);
        }

        public static String ToString(ICodeGenObject obj)
        {
            using (var writer = new CodeGenWriter())
            {
                obj.Write(writer);
                writer.Flush();

                return writer.ToString();
            }
        }
    }
}